﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebStudio.Business.Rule;
using WebStudio.Business.Entity;

public partial class Admin_FrdLinkMge : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Admin_User"] == null || Session["Admin_User"].ToString() == "")
        {
            Response.Redirect("~/Admin/Login.aspx");
        }
        if (!Page.IsPostBack)
        {
            InitPage();
        }
    }

    private void InitPage()
    {
        anpList.PageSize = 15;
        anpList.CurrentPageIndex = 1;
        anpList.RecordCount = FriendUrlRule.GetFriendUrlListCount();
        rptFrdLinkBind();
    }

    private void rptFrdLinkBind()
    {
        rptFrdLink.DataSource = FriendUrlRule.GetFriendUrlList(anpList.CurrentPageIndex, anpList.PageSize, anpList.PageCount, anpList.RecordCount);
        rptFrdLink.DataBind();
    }

    protected void anpList_PageChanged(object sender, EventArgs e)
    {
        rptFrdLinkBind();
    }

    protected void rptFrdLink_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "delete")
        {
            LinkButton lbtnDelete = e.Item.FindControl("lbtnDelete") as LinkButton;
            FriendUrlRule.DeleteFriendUrlInfor(Convert.ToInt32(lbtnDelete.CommandArgument));
            rptFrdLinkBind();
        }
    }
}
